
import java.util.Scanner;

public class IntTree {
	private ReplaceableTree tree;
	
	public IntTree(int node) {
		tree = new ReplaceableTree(String.valueOf(node));
	}
	
	public IntTree() {
		tree = new ReplaceableTree();
	}
	
	public String search(int node){
		return tree.search(String.valueOf(node));
	}
	
	public void add(int node){
		tree.add(String.valueOf(node));
	}
		
	public boolean contains(int node) {
		return tree.contains(String.valueOf(node));
	}
	
	@Override
	public String toString() {
		return tree.toString();
	}
	
	public void replace(String position, String subTree) {
		Scanner s = new Scanner(subTree).useDelimiter("\n");
		String temp;
		while(s.hasNext()) {
			temp = s.next();
			temp = temp.replace('-', ' ');
			temp = temp.trim();
			try {
				if(temp.length()>0)
				Integer.parseInt(temp);
			} catch (Exception e) {
				System.out.println(e);
				return;
			}
		}
		tree.replace(position, subTree);
	}
}
